package biznussoft.metercor.utils;

import biznussoft.metercor.R;

import android.app.AlertDialog;
import android.content.Context;
import android.content.res.Resources;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.animation.AnimationUtils;

public class ProgressDialog {

	 private static final ProgressDialog INSTANCE = new ProgressDialog();

	    public static ProgressDialog getInstance() {
	        return INSTANCE;
	    }

	
	public AlertDialog createProgressDialog(Context context) {
        View progressBar;
        progressBar = View.inflate(context, R.layout.spinner, null);
        progressBar.findViewById(R.id.spinner).startAnimation(AnimationUtils.loadAnimation(context, R.anim.rotate));

        int yPadding = (int) convertDpToPixel(15, context);
        int xPadding = (int) convertDpToPixel(15, context);
        progressBar.setPadding(xPadding, yPadding, xPadding, yPadding);

        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setView(progressBar);
        return builder.create();
    }
	
	 public float convertDpToPixel(float dp, Context context) {
	        Resources resources = context.getResources();
	        DisplayMetrics metrics = resources.getDisplayMetrics();
	        return dp * (metrics.densityDpi / 160f);
	    }

	
}
